//
//  ShopTotalCommentCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/17.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "ShopTotalCommentCell.h"
#import "CreateSpaceModel.h"
#import "ShopInfo.h"

@interface ShopTotalCommentCell ()

@property (nonatomic, strong) UIView *totalView;
@property (nonatomic, strong) UIView *qualityView;
@property (nonatomic, strong) UIView *speedView;
@property (nonatomic, strong) UIView *attitudeView;

@end

@implementation ShopTotalCommentCell

+ (ShopTotalCommentCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"ShopTotalCommentCell";
    ShopTotalCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ShopTotalCommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@interface FirstPageCell ()

@property (nonatomic, strong) UIImageView   *productImage;
@property (nonatomic, strong) UILabel       *productName;
@property (nonatomic, strong) UILabel       *price;

@end

@implementation FirstPageCell

+ (FirstPageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"FirstPageCell";
    FirstPageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[FirstPageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    return cell;
}

- (void)createSubView {
    _productImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(349), ScreenX375(154))];
    _productImage.layer.cornerRadius = 5.0;
    _productImage.userInteractionEnabled = YES;
    [self addSubview: _productImage];
    
    _deleteBtn =[[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(326), ScreenX375(0), ScreenX375(23), ScreenX375(23))];
    _deleteBtn.backgroundColor = ThemeColor;
    [_deleteBtn setImage:[UIImage imageNamed:@"删除"] forState:UIControlStateNormal];
    _deleteBtn.layer.cornerRadius = 11.5;
    [_deleteBtn addTarget:self action:@selector(removeGoods) forControlEvents:UIControlEventTouchUpInside];
    [_productImage addSubview:_deleteBtn];
    
    _productName =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(179), ScreenX375(250), ScreenX375(16))];
    _productName.font = Kfont(14);
    _productName.textColor = REXADECIMALCOLOR(@"#333333");
    _productName.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_productName];

    _price =[[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(113), ScreenX375(179), ScreenX375(100), ScreenX375(12))];
    _price.font = Kfont(14);
    _price.textColor = ThemeColor;
    _price.textAlignment = NSTextAlignmentRight;
    [self addSubview:_price];
}

- (void)removeGoods {
    if (_deleteClick) {
        _deleteClick();
    }
}

-(void)initwithModel:(CreateSpaceModel *)model{
    [_productImage sd_setImageWithURL:[NSURL URLWithString:model.pic] placeholderImage:nil options:SDWebImageRetryFailed];
    if (model.design_name) {
        _productName.text = model.design_name;
        _price.text = [NSString stringWithFormat:@"¥%@",model.price];
    }
}

- (void)initWithDic:(NSDictionary *)dict {
    [_productImage sd_setImageWithURL:[NSURL URLWithString:dict[@"pic"]] placeholderImage:nil options:SDWebImageRetryFailed];
    if ([dict[@"name"] class] != [NSNull class]) {
        _productName.text = dict[@"name"];
        _price.text = [NSString stringWithFormat:@"¥%@",dict[@"price"]];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

@interface SecondPageCell ()

@property (nonatomic, strong) UIImageView   *imgView;
@property (nonatomic, strong) UILabel       *title;
@property (nonatomic, strong) UILabel       *information;
@property (nonatomic, strong) UILabel       *price;
@property (nonatomic, strong) UIButton      *more;
@end

@implementation SecondPageCell

+ (SecondPageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"SecondPageCell";
    SecondPageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[SecondPageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(103), ScreenX375(71))];
    _imgView.image = [UIImage imageNamed:@"头部背景"];
    _imgView.clipsToBounds = YES;
    _imgView.layer.cornerRadius = 5.0;
    [self addSubview: _imgView];
    
    
    _title =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(15), ScreenX375(230), ScreenX375(14))];
    _title.text = @"公司包装设计 / 商标设计 / LOGO设计";
    _title.font = Kfont(14);
    _title.textColor = REXADECIMALCOLOR(@"#333333");
    _title.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_title];
    
    _information =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(37), ScreenX375(230), ScreenX375(14))];
    _information.text = @"成交2243笔 | 服务评分：4.98分";
    _information.font = Kfont(14);
    _information.textColor = REXADECIMALCOLOR(@"#999999");
    _information.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_information];
    
    _price =[[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(126), ScreenX375(74), ScreenX375(200), ScreenX375(14))];
    _price.text = @"1200 元";
    _price.font = Kfont(14);
    _price.textColor = ThemeColor;
    _price.textAlignment = NSTextAlignmentLeft;
    [self addSubview:_price];
    
    _more =[[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(355), ScreenX375(45), ScreenX375(7), ScreenX375(12))];
    [_more setImage:[UIImage imageNamed:@"更多"] forState:UIControlStateNormal];
    [self addSubview:_more];

    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(99), ScreenX375(349), ScreenX375(1))];
    UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"虚线"]];
    [line setBackgroundColor:color];
    [self addSubview:line];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

@interface ThirdPageCell ()

@property (nonatomic, strong) UIButton    *submit;

@end

@implementation ThirdPageCell

+ (ThirdPageCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"ThirdPageCell";
    ThirdPageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[ThirdPageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    _submit =[[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(28), ScreenX375(349), ScreenX375(44))];
    [_submit setTitle:@"+添加商品" forState:UIControlStateNormal];
    [_submit setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _submit.backgroundColor = ThemeColor;
    _submit.layer.cornerRadius = 22.0;
    [self addSubview:_submit];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end

